package com.haoshuang.zhouzhoubang.ui.page.order.take

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.TakeOrderBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class TakeOrderViewModel : BaseViewModel() {

    /**
     * 门店下单
     */
    val teamAddOrderData = StatefulMutableLiveData<TakeOrderBean>()
    fun teamAddOrder(
        product_id: String,
        suk_unique: String,
        pay_price: String,
        add_pay_price: String,
        discount_pay_price: String,
        service_day: String,
        service_time: String,
        user_phone: String,
        real_name: String,
        mark: String,
        province_id: String,
        city_id: String,
        area_id: String,
        detail: String,
        house_number: String,
        key_areas: String,
    ) = netRequest {
        start { teamAddOrderData.value = StateData.Loading }
        request {
            ApiRepo.teamAddOrder(
                product_id,
                suk_unique,
                pay_price,
                add_pay_price,
                discount_pay_price,
                service_day,
                service_time,
                user_phone,
                real_name,
                mark,
                province_id,
                city_id,
                area_id,
                detail,
                house_number,
                key_areas,
            )
        }
        success { teamAddOrderData.value = StateData.Success(it.data) }
        error { code, msg ->
            teamAddOrderData.value = StateData.Error(code, msg)
        }
    }

}